Repository navigation
Import zod/v3 and allow zod 4 as a dependency range - #309
Open
dtheurer-control4 wants to merge 1 commit into
Open
dtheurer-control4 wants to merge 1 commit into
dtheurer-control4 wants to merge 1 commit into
Conversation
The package imports the bare "zod" root, whose API changes between majors, and declares zod ^3.25.67 as a hard dependency, so a consumer on zod 4 (for example the MCP TypeScript SDK) installs a second, nested zod 3 copy of this package's dependency. Import from "zod/v3" (available since zod 3.25.0 and shipped by zod 4) and widen the range to ^3.25.67 || ^4.0.0, as the Zod library-author guide recommends. zod-to-json-schema keeps receiving v3 schemas. yarn.lock updated (resolves 4.6.7 now that the range allows it).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The package imports the bare
"zod"root in 13 source files and declareszod: ^3.25.67as a hard dependency. The root export changes between Zod majors, and the hard dependency means any project that uses Zod 4 (for example the MCP TypeScript SDK) installs a second, nested Zod 3 copy of this package's dependency. Projects that runnpm auditthen see advisories that affectzod <4.6.6on the nested copy, with no way to resolve them except a package-manager override.Change
"zod/v3"instead of"zod"(the subpath exists since Zod 3.25.0 and is shipped by Zod 4), as recommended in the Zod library-author guide (https://zod.dev/library-authors). The schemas stay Zod 3 schemas, sozod-to-json-schemakeeps receiving the input it expects.^3.25.67 || ^4.0.0.yarn.lockupdated; with the wider range yarn resolves 4.6.7 and prints a peer warning forzod-to-json-schema(peer^3.24.1), which the maintainers may prefer to handle by keeping the resolution on 3.25.x.Testing
Run with npm in a scratch checkout (not the repo's yarn setup): with zod 3.25.76 and with zod 4.6.7 the Jest results are identical (59 passed, 8 failed, 1 pre-existing
tscerror insrc/node/sign.ts; the failures are unrelated to Zod in my environment). With the old bare import under Zod 4, one more test fails. I did not run the full upstream CI, so please treat the unrelated failures as environment noise until CI confirms.Happy to adjust (for example to make Zod a peer dependency instead).
🤖 Generated with Claude Code